﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Microsoft.AspNet.SignalR;
using WebApplication2.SignalR;

namespace WebApplication2.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        public ActionResult UserChat(string target,string orderNO)
        {
            ViewBag.target = target;
            ViewBag.orderNO = orderNO;
            IHubContext chat = GlobalHost.ConnectionManager.GetHubContext<UserHub>();

            if (!string.IsNullOrWhiteSpace(target))
            {
                var userid = UserHub.users.FirstOrDefault(s => s.Name == target);
                chat.Clients.Client(userid.ConnectionID).notify("成功C");
                //chat.Clients.User(target).notify("成功C");
            }
            return View();
        }
    }
}